/*
 * Copyright (c) 2003, 2004 Ulrich Hilger, http://dev.uhilger.de, all rights reserved.
 *
 * Published under the terms and conditions of the Apache License 2.0,
 * see http://www.apache.org/licenses/LICENSE-2.0
 */

package de.uhilger.app.mdi;

import de.uhilger.app.DefaultApplication;
import de.uhilger.app.mdi.ui.MDIMainFrame;
import java.util.logging.Level;
import de.uhilger.app.mdi.ui.WindowMenu;
import de.uhilger.app.mdi.ui.MDIDesktopPane;

/**
 * An application that implements a multiple document interface (MDI) 
 * to subclass from.
 *
 * @author Ulrich Hilger, <a href="http://dev.uhilger.de" target="_blank">http://dev.uhilger.de</a>
 * @author Published under the terms and conditions of
 * the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License 2.0</a>
 *
 * @version 1, February 12, 2004
 */

public class MDIApplication extends DefaultApplication {

  public MDIApplication() {
    super();
  }

  public MDIApplication(Level level, String logDir) {
    this(level, logDir, true);
  }

  public MDIApplication(Level level, String logDir, boolean showUi) {
    super(level, logDir, showUi);
  }

  /**
   * initialize this application's main frame
   */
  protected void initMainFrame(boolean showUi) {
    // create a window menu
    desktop = new MDIDesktopPane();
    WindowMenu wm = new WindowMenu(desktop,
                                   getResourceString(WindowMenu.WM_CASCADE_LABEL),
                                   getResourceString(WindowMenu.WM_TILE_LABEL),
                                   getResourceString(WindowMenu.WM_WINDOW_LABEL));

    // create the application's main frame
    MDIMainFrame mf = new MDIMainFrame(this, getAppName(), wm, desktop);

    if (showUi) {
      mf.setLocationRelativeTo(null);
    }
    mf.setVisible(showUi);
  }

  public MDIDesktopPane getDesktop() {
    return desktop;
  }

  /** the desktop pane of this application */
  private MDIDesktopPane desktop;

}
